import java.util.Scanner;
import java.util.InputMismatchException;

public class Main {
    public static void funcction() throws ArrayIndexOutOfBoundsException {
        int[] arr = {1, 2, 3};
        System.out.println(arr[100]);
    }

    public static void main(String[] args) {
        try {
            funcction();
        } catch (ArrayIndexOutOfBoundsException e) {

        } finally {

        }

    }


    public static int getData() {
        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
            int data = sc.nextInt();
            return data;
        } catch (InputMismatchException e) {
            e.printStackTrace();
        } finally {
            System.out.println("finally中代码");
        }


        System.out.println("try-catch-finally之后代码");
        if (null != sc) {
            sc.close();
        }
        return 0;
    }

    public static void main11111(String[] args) {
        int data = getData();
        System.out.println(data);
    }

    public static int func() {
        Scanner scanner = new Scanner(System.in);
        try {
            return 10;
        } catch (NullPointerException e) {
            System.out.println("捕获到了一个空指针异常！");
        } finally {
            //一般用来 释放资源
            scanner.close();
            System.out.println("这里执行了finally，一定会被执行！");
        }
        return 100;
    }

    public static int func2() {

        try (Scanner scanner = new Scanner(System.in)) {
            return 10;
        } catch (NullPointerException e) {
            System.out.println("捕获到了一个空指针异常！");
        } finally {
            //一般用来 释放资源
            System.out.println("这里执行了finally，一定会被执行！");
        }
        return 100;
    }
}